<?php

namespace app\admin\validate;

use think\Validate;

class Communityinfo extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'community_name' => 'require|max:100',
        'teaching_point_id' => 'require|number|gt:0',
        'address' => 'require|max:255',
        'contact_person' => 'require|max:50',
        'phone' => 'require|mobile',
        'description' => 'max:1000',
        'admin_user_id' => 'require|number|gt:0',
        'status' => 'in:0,1',
        'weigh' => 'number',
    ];
    
    /**
     * 提示消息
     */
    protected $message = [
        'community_name.require' => '社区名称不能为空',
        'community_name.max' => '社区名称最多100个字符',
        'teaching_point_id.require' => '教学点不能为空',
        'teaching_point_id.number' => '教学点必须是数字',
        'teaching_point_id.gt' => '请选择有效的教学点',
        'address.require' => '详细地址不能为空',
        'address.max' => '详细地址最多255个字符',
        'contact_person.require' => '联系人不能为空',
        'contact_person.max' => '联系人最多50个字符',
        'phone.require' => '联系电话不能为空',
        'phone.mobile' => '联系电话格式不正确',
        'description.max' => '描述信息最多1000个字符',
        'admin_user_id.require' => '管理员用户不能为空',
        'admin_user_id.number' => '管理员用户必须是数字',
        'admin_user_id.gt' => '请选择有效的管理员用户',
        'status.in' => '状态只能是0或1',
        'weigh.number' => '权重必须是数字',
    ];
    
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['community_name', 'teaching_point_id', 'address', 'contact_person', 'phone', 'description', 'admin_user_id', 'status', 'weigh'],
        'edit' => ['community_name', 'teaching_point_id', 'address', 'contact_person', 'phone', 'description', 'admin_user_id', 'status', 'weigh'],
    ];
}